﻿@model Fish.Models.EventInfo

@{
    ViewBag.Title = "Details";
}
@section scripts{
    <style>
        #map-canvas {
            height: 100%;
            margin: 0px;
            padding-bottom: 200px;
            padding-left: 300px;
            left: 100px;
            width: 500px;
            top: -5px;
        }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>

        var geocoder;
        var map;
        function initialize() {
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var mapOptions = {
                zoom: 15,
                center: latlng
            }
            
            map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
            codeAddress();
        }


        function codeAddress() {
            var address = document.getElementById('Address').value;
            geocoder.geocode({ 'address': address }, function (results, status) {

                if (status == google.maps.GeocoderStatus.OK) {

                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location

                    });

                } else {
                    document.getElementById('locationError').hidden = false;
                }
            });
        }

        google.maps.event.addDomListener(window, 'load', initialize);


    </script>

}





<div id="options">
    <input id="Address" name="Address" value="@Model.Address" hidden="hidden" />


    @foreach (var tb in Model.Event.Template.Tabs)
    {
        if (tb.number == 0)
        {
            <p>@Html.ActionLink("Supplies", "Index", "Supplies", new { eventID = Model.Event.ID }, null)</p>
        }
        if (tb.number == 1)
        {
            <p>@Html.ActionLink("Transport", "Index", "Transports", new { eventID = Model.Event.ID }, null)</p>
        }
        if (tb.number == 2)
        {
            <p>@Html.ActionLink("Wall Posts", "Index", "WallPosts", new { eventID = Model.Event.ID }, null)</p>
        }
    }
    @{
        for (var i = 0; i < Model.Event.Template.Customized.Count; i++)
        {
            <p>@Html.ActionLink(@Model.Event.Template.Customized.ElementAt(i).Name, "Create", "Customized", new { templateId = Model.Event.TemplatesID, Tab = i }, null)</p>
        }
    }
</div>


<div id="attributes">

    <h3><b>@Model.Event.Name</b></h3>
    <hr />
    <dl class="dl-horizontal">

           

        <dt>
            @Html.DisplayNameFor(model => model.Description)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Description)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.StartDate)
        </dt>

        <dd>
            @Html.DisplayTextFor(model => model.StartDate)
        </dd>
        @if (Model.EndDate.Year == 1) { 
        <dt>
            @Html.DisplayNameFor(model => model.EndDate)
        </dt>

        <dd>
            @Html.DisplayTextFor(model => model.EndDate)
        </dd>
        }
        <dt>
            @Html.DisplayName("Maximum Guests")
        </dt>

        <dd>
            @if (@Model.MaximumGuests > 0)
            {
                @Html.DisplayFor(model => model.MaximumGuests)
            }
            else
            {
                @Html.DisplayName("Unlimited")
            }
        </dd>
        <dt>
            @Html.DisplayNameFor(model => model.Address)
        </dt>

        <dd>
            @Html.DisplayTextFor(model => model.Address)
        </dd>
    </dl>
</div>
<div style="min-height:200px"></div>
<div id="map-canvas"></div>
<label id="locationError" hidden="hidden">The Location for this event has not been set</label>


<div>
    <p>
        @if (!Model.isMember(int.Parse(Session["userID"].ToString())))
        {
            @Html.ActionLink("I want to come!", "AddGuest", "EventUserRelations")
        }

        <br /><br /><br />
        @Html.ActionLink("Invite Friends", "Invite", new { id = Model.ID }) |
        @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
        @Html.ActionLink("Back to Events", "Index", "EventUserRelations")
    </p>
</div>

<div class="fb-share-button" data-href="http://developers.facebook.com/docs/plugins/" data-type="button_count"></div>


<div id="fb-root"></div>
<script>
    (function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>